# This is a sample Python script.

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
import generate_data
import json
import alchemy


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press ⌘F8 to toggle the breakpoint.


def get_data(iter=1):
    records = []
    for i in range(0, iter):
        record = []
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_int())

        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_time())
        record.append(generate_data.generate_random_time())

        record.append(generate_data.generate_random_float())
        record.append(generate_data.generate_random_float())
        record.append(generate_data.generate_random_float())
        record.append(generate_data.generate_random_choice(['0', '1', '2', '3']))
        record.append(generate_data.generate_random_float())

        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_string())

        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_int())

        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_float())
        record.append(generate_data.generate_random_float())
        record.append(generate_data.generate_random_choice(['A', 'B', 'C', 'D', 'E']))

        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_time())
        record.append(generate_data.generate_random_time())

        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_int())
        record.append(generate_data.generate_random_string())
        record.append(generate_data.generate_random_string())

        record.append(generate_data.generate_random_choice(['2023', '2024', '2025']))

        d = {'name': 'xpleaf'}
        record.append(json.dumps(d))
        records.append(record)

    return records


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    '''
        for record in get_data():
        insert(record)
    '''

    data = generate_data.generate_random_data(iter=1, db_type='mysql')
    engine = alchemy.new_engine_by_db_type(db_type='mysql')

    for d in data:
        alchemy.insert_data(
            engine=engine,
            table_name='t_field_type',
            data=d
        )
